export const orderDatas = [
  {
    project: '拼车',
    num: 1,
  },
  {
    project: '包车',
    num: 1,
  },
  {
    project: '货件',
    num: 1,
  },
  {
    project: '已超时',
    num: 1,
  },
]
const apiOrderMap = {
  拼车: 'order_type0_count',
  包车: 'order_type1_count',
  货件: 'order_type2_count',
  已超时: 'expire_count',
}
export const updateOrderData = apiData => {
  return orderDatas.map(order => ({
    ...order,
    num: parseInt(apiData[apiOrderMap[order.project]]) || 0,
  }))
}
export const transports = [
  {
    project: '5座',
    num: 5,
  },
  {
    project: '7座',
    num: 0,
  },
  {
    project: '返程中',
    num: 0,
  },
]
const apiTransportMap = {
  '5座': 'seats_5',
  '7座': 'seats_7',
  返程中: 'return_count',
}
export const updateTransportData = apiData => {
  return transports.map(transport => ({
    ...transport,
    num: parseInt(apiData[apiTransportMap[transport.project]]) || 0,
  }))
}
export const totalDatas = [
  {
    project: '总订单数（去重）',
    num: 0,
  },
  {
    project: '完成订单数',
    num: 0,
  },
  {
    project: '消单率',
    num: 0,
  },
  {
    project: '总载客数',
    num: 0,
  },
  {
    project: '总边次',
    num: 0,
  },
  {
    project: '用车数',
    num: 0,
  },
  {
    project: '上座率',
    num: 0,
  },
  {
    project: '撮合成功订单数',
    num: 0,
  },
  {
    project: '人工干预订单',
    num: 0,
  },
  {
    project: '人工干预边次',
    num: 0,
  },
  {
    project: '司机行驶里程',
    num: 0,
  },
  {
    project: '司机行驶时长',
    num: 0,
  },
  {
    project: '平均行驶里程',
    num: 0,
  },
  {
    project: '平均行驶时长',
    num: 1,
  },
]
const apiTotalMap = {
  '总订单数（去重）': 'all_true_count',
  完成订单数: 'finished_count',
  消单率: 'cancel_true_count /all_true_count',
  总载客数: 'all_user_count',
  总边次: 'all_dispatched_count',
  用车数: 'all_car_number',
  上座率: 'all_user_count /(all_car_number *seat_capacity)',
  撮合成功订单数: 'matched_order_count',
  人工干预订单: 'man_order_count',
  人工干预边次: 'man_dispatched_count',
  司机行驶里程: 'all_distance',
  司机行驶时长: 'all_duration',
  平均行驶里程: 'avg_distance',
  平均行驶时长: 'avg_duration',
}
export const updateTotalData = apiData => {
  return totalDatas.map(total => ({
    ...total,
    num: parseInt(apiData[apiTotalMap[total.project]]) || 0,
  }))
}
